﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ClientRegister
{
    public partial class CheckForm : Form
    {
        public CheckForm()
        {
            InitializeComponent();
        }

        private void CheckForm_Load(object sender, EventArgs e)
        {
            //创建一个线程任务，验证
            //Thread  Task
            Task taskCheck = new Task(() => Check());
            taskCheck.Start();//开启一个线程

        }

        public void Check()
        {
            Thread.Sleep(2000);
            //拥有此窗口的句柄上创建委托任务
            //控制台很多知识点
            //true:已授权
            this.FindForm().Invoke(new Action(() =>
            {
                this.Visible = false;//隐藏检查窗体（主窗体）
                if (false)
                {
                    MainForm mainForm = new MainForm();
                    mainForm.Show();
                }
                else
                {
                    RegisterForm rf = new RegisterForm();
                    rf.Show();
                }

            }));


        }
    }
}
